<template>
  <div class="informationShow">
    <el-row :gutter="30" :data="data" >
      <div :class="detailInfoWrap">
        <el-col :span="24" class="mgb10" ><b>{{option.title}}</b></el-col>
        <el-col  class="mb5" :span="item.span" v-for="(item, index) in option.column" :key="index" style="border: 1px solid #ccc;">
          <span style="width: 100px; display: inline-block; text-align: left;">{{item.label}}:</span>
          <span style="border: 1px #ccc solid;"></span>
          <span v-if="item.type!=='sensitive' "> {{item | dataDicTrans(data)}}</span>
          <span v-else>
            <span v-if="!item.showFull">{{ item | dataDicTrans(data) | customerNoDesensitization }}</span>  
            <span v-else>{{ item | dataDicTrans(data) }}</span> 
            <el-button icon="el-icon-view" 
                      @click="toggleShowFull(item)" 
                      v-if="item.label==='移动电话' || item.label==='证件号码'"
                      class="showEye">
            </el-button> 
          </span>
          
        </el-col>
      </div>
      <!-- <el-col :span="24" class="detailInfoBtn">
        <el-button class="custInfoBtn" @click="custInfoBtn" v-html="custInfoBtnTit"></el-button>
      </el-col> -->
    </el-row>
  </div>
</template>

<script>
  import {dataDicTrans} from '@/api/bankBiz/loss/loss'
  import {customerNoDesensitization} from '@/api/hubeixiaojin/HbUtils';
  export default {
    name: 'informationShow',
    props: ['data', 'option'],
    data () {
      return {
        detailInfoWrap: 'cus-info-simple',
        custInfoBtnTit: '详细信息'
      }
    },

    filters: {  
      // maskSensitiveData(value) {  
      //   // 假设是银行卡或手机号，只显示前几位和后几位  
      //   return value.replace(/(\d{4})\d+(\d{4})/, '$1****$2');  
      // },
      customerNoDesensitization
    },


    mounted () {
//      console.log('111' + dataDicTrans)
    },
    methods: {
    //  dataDicTrans(item, data) {
    //    dataDicTrans(item, data)


    //  },
      custInfoBtn () {
        this.detailInfoWrap = this.detailInfoWrap == 'cus-info-simple' ? 'cus-info-detail' : 'cus-info-simple'
        if (this.detailInfoWrap == 'cus-info-simple') {
          this.custInfoBtnTit = '详细信息'
        } else {
          this.custInfoBtnTit = '收起'
        }
      },

      //展示完整证件号码或手机号码
      toggleShowFull(item){
        var data = sessionStorage
        var userInfo = data.userInfo
        console.log('userInfo：')
        console.log(userInfo)
        if(userInfo!=undefined && userInfo.length>0){
          var userInfoObj = JSON.parse(userInfo)
          var contentObj = userInfoObj.content
          var resources = contentObj.resources
          if(resources.includes('sensitive')){
            this.$set(item, 'showFull', !item.showFull); 
            //console.log(item)
          }else{
            console.log('没有查看完全敏感数据的权限！')
          }



        }else{
          console.log('没有查看完全敏感数据的权限.')
        }

      }





    },




  }
</script>

<style scoped>

  .mb5 {
    margin-bottom: 0px;
  }

  .informationShow .el-col {
    line-height: 18px;
  }
  .mgb10 {
    margin-bottom: 10px;
  }

  .cus-info-simple {
    height: 180px;
    overflow: hidden;
  }

  .cus-info-detail {
    height: auto;
    overflow: hidden;
  }

  .detailInfoBtn {
    text-align: right;
    height: 40px;
    line-height: 40px;
    border-top: 1px #ccc dashed;
    padding-top: 8px;
  }
  .showEye {
    background-color: transparent; /* 透明背景 */  
    border: none; /* 无边框 */  
    color: #409EFF; /* 字体颜色，可根据需要调整 */  
    padding: 0; /* 无内边距 */  
    margin-left: 5px; /* 与文本保持一定距离 */ 
     float:right

  }
  .showEye:hover {
    color: #f53b07; /* 鼠标悬停时的字体颜色 */ 
  }
</style>
